package com.ouman.luoliluoli.utils;

import java.util.Calendar;

/**
 * Created by jintian on 26/05/2017.
 */

public class TimeDisplayHelper {

    public static String displayTime(String timeString){
        // this method will return a displayable string of time
        // send value could be "2017-5-6 4:23"
        // will return 5月6号 4点

        Calendar cal = Calendar.getInstance();
        Integer calYear = cal.get(Calendar.YEAR);
        Integer calMonth = cal.get(Calendar.MONTH);
        Integer calDay = cal.get(Calendar.DAY_OF_MONTH);

        String datePart = timeString.split(" ")[0];
        String timePart = timeString.split(" ")[1];

        String month = datePart.split("-")[1];
        String day = datePart.split("-")[2];
        if (day.equals(calDay.toString())){
            // 说明是今天
            return "今天 " + timePart;
        } else {
            return month + "月" + day + "号 " + timePart;
        }
    }
}
